<%--
  Created by IntelliJ IDEA.
  User: mona
  Date: 2020/5/28
  Time: 16:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员界面</title>
    <link rel="shortcut icon" href="#" />
    <link rel="stylesheet" href="../element-ui/element.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/cln/css/admin.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/cln/css/carmanage.css">
</head>
<body>
<script src="../../vue/vue.js"></script>
<script src="../../vue/vue.min.js"></script>
<script src="../element-ui/element.js"></script>
<script src="../../jquery/jquery-3.4.1.js"></script>
<div>
    <div style="height: 80px; line-height: 80px">
        <h3 id="h3"></h3>
        <div class="exitadmin" onclick="exitsystem()">退出登录</div>
    </div>
    <div class="nav-left" id="admin">
        <template>
            <el-row class="tac" >
                <el-col :span="3">
                    <el-menu default-active="2" class="el-menu-vertical-demo"
                             @open="handleOpen" @close="handleClose">
                        <el-menu-item index="1">
                            <span slot="title">用户管理</span>
                        </el-menu-item>
                        <el-submenu index="2">
                            <template slot="title">
                                <span>商品管理</span>
                            </template>
                            <el-menu-item-group>
                                <template slot="title">汽车信息管理</template>
                                <el-menu-item index="1-1" id="car">汽车管理</el-menu-item>
                                <el-menu-item index="1-2">基本信息管理</el-menu-item>
                            </el-menu-item-group>
                            <el-menu-item-group title="汽车基本配置管理">
                                <el-menu-item index="1-3">发动机管理</el-menu-item>
                                <el-menu-item index="1-4">变速箱管理</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <el-menu-item index="3">
                            <span slot="title">帖子管理</span>
                        </el-menu-item>
                        <el-menu-item index="4">
                            <span slot="title">文章管理</span>
                        </el-menu-item>
                    </el-menu>
                </el-col>
            </el-row>
        </template>
    </div>
</div>
</body>
<script>
    //退出系统
    function exitsystem() {
        $.ajax({
            method: 'get',
            url: '/forum/admin/logout',
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.state === '200') {
                    window.location.href = "adminlogin.jsp";
                }
            }
        })
    }

    var Main = {
        created() {
            //页面加载时获取登录信息
            this.getAdminInfo()
        },
        methods: {
            handleOpen(key, keyPath) {
                console.log(key, keyPath);
            },
            handleClose(key, keyPath) {
                console.log(key, keyPath);
            },
            //获取登录信息
            getAdminInfo() {
                $.ajax({
                    method: 'get',
                    url: '/forum/admin/getAdminInfo',
                    dataType: 'json',
                    success: function (data) {
                        console.log(data.data);
                        if (data.state === '200') {
                            $('#h3').append("欢迎");
                            $('#h3').append(data.data.adminName);
                        }
                    }
                })
            }
        }
    };
    var Ctor = Vue.extend(Main);
    new Ctor().$mount("#admin");
    
    <%--function carmanage() {--%>
        <%--$('#car').click(function () {--%>
            <%--$('#car').append('<div><jsp:include page="carmanage.jsp"></jsp:include></div>');--%>
        <%--})--%>
    <%--}--%>
</script>
</html>
